package service.employee;

import java.rmi.RemoteException;

import business.BusinessFacade;
import employee.entities.EmployeeVO;
import employee.exceptions.IncompleteEmployeeException;
import employee.interfaces.EmployeeRemoteMgt;

public class EmployeeRemoteMgr implements EmployeeRemoteMgt {

	private static EmployeeRemoteMgr instance;

	private EmployeeRemoteMgr() {
	}

	public static EmployeeRemoteMgr getInstance() {
		if (instance == null)
			instance = new EmployeeRemoteMgr();
		return instance;
	}

	public EmployeeVO[] getEmployees() {
		return BusinessFacade.getInstance().getEmployeeMgt().getEmployees();

	}

	public EmployeeVO getEmployee(int id) throws RemoteException {
		return BusinessFacade.getInstance().getEmployeeMgt().getEmployee(id);
	}

	public void update(EmployeeVO emp) throws RemoteException,
			IncompleteEmployeeException {
		BusinessFacade.getInstance().getEmployeeMgt().update(emp);

	}

	public void delete(int id) throws RemoteException {
		BusinessFacade.getInstance().getEmployeeMgt().delete(id);
	}

	public void add(EmployeeVO emp) throws RemoteException,
			IncompleteEmployeeException {
		BusinessFacade.getInstance().getEmployeeMgt().add(emp);
	}

	public boolean authenticate(EmployeeVO emp, String pass)
			throws RemoteException, IncompleteEmployeeException {
		return BusinessFacade.getInstance().getEmployeeMgt()
				.authenticate(emp, pass);
	}
}
